package com.lpit.zookeeper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 生成注解功能类
 */
@Component
public class Sequences {

    @Autowired
    private ZooKeeperClient zooKeeperClient;

    /**
     * 生成一个主键
     * @return
     * @throws Exception
     */
    public Long sequenceUser() throws Exception {
        return this.zooKeeperClient.sequence(ZkSequenceEnum.USER);
    }

    public Long sequenceArticle() throws Exception {
        return this.zooKeeperClient.sequence(ZkSequenceEnum.ARTICLE);
    }
}
